#include <stdio.h>
#include "studentList.h"

void Save_Student_Data(STUDENT *head,FILE *p)
{
	if (p == NULL || head == NULL)
	{
		return;
	}
	STUDENT *phead = head->next;
	fprintf(p,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
	fprintf(p,"<STUDENT>\n");
	while (phead != NULL)
	{
		fprintf(p,"	<student>\n");
		fprintf(p,"		<number>%s</number>\n", phead->number);
		fprintf(p,"		<name>%s</name>\n", phead->name);
		fprintf(p,"		<phone>%s</phone>\n", phead->phone);
		if (phead->scores != NULL)
		{
			fprintf(p,"  	<SCORES>\n");
			fprintf(p,"    		<Chinese>%d</Chinese>\n", phead->scores->Chinese);
			fprintf(p,"    		<Math>%d</Math>\n", phead->scores->Math);
			fprintf(p,"    		<English>%d</English>\n", phead->scores->English);
			fprintf(p,"  	</SCORES>\n");;
		}
		fprintf(p,"	</student>\n");
		phead = phead->next;
	}
	fprintf(p,"</STUDENT>\n");
}
